<extend name="Base/mob_common"/>
<block name="mob_body">
<div class="addpost-container" style="padding: 10px;">
    <script src="__JS__/blog.js"></script>
    <link rel="stylesheet" href="__CSS__/apps/blog.css"/>
    <script src="__JS__/amazeui.datetimepicker.min.js"></script>
    <link rel="stylesheet" href="__CSS__/amazeui.datetimepicker.css"/>

    <form class="am-form" data-am-validator id="send_blog" data-url="{:U('Mob/blog/doSendBlog')}">
        <input type="hidden" id="img_ids" name="attach_ids" value="">
        <input type="hidden" id="one_img_id" name="one_attach_id" value="{$blog.cover}">
        <input type="hidden" id="id" name="id" value="{$blog.id}">
        <!--插入图片-->
        <div class="am-cf " style="padding: 10px;">
            <div class="am-fl">
                <div class="img_btn">
                    <i class="am-icon-plus" style="font-size: 25px;padding: 12px 20px;"></i>
                </div>

                <input type="file" name="files" id="chooseOne" class=" am-btn"
                       style="left:10px;top: 60px;position:absolute;z-index: 1;width: 72px;height:72px;opacity: 0;cursor: pointer;">
            </div>
            <div class="show_cover am-fl" style="display:none;margin-left: 10px;">
                <div id="cover_url">
                    <img class="cover_img"style="width:74px;height: 74px" src="{$blog.cover_url}">
                </div>
            </div>

        </div>
        <!--插入图片结束-->
        <!--标题-->
        <div class="am-form-group">
            <label>标题</label>
            <input type="text" name="title" minlength="1" placeholder="标题" class="am-form-field"  value="{$blog.title}" required/>
        </div>

        <!--选择模块-->
        <div class="am-form-group am-form-inline">
            <label>分类</label>
            <select id="category" name="category" class="form-control">
                <volist name="category" id="top">
                    <option value="{$top.id}"
                    <eq name="data['category']" value="$top['id']"> selected</eq>
                    >
                    {$top.title}
                    </option>
                </volist>
            </select>
            <span class="am-form-caret"></span>
        </div>

        <div class="am-form-group">
            <label>来源</label>
            <input type="text" minlength="1" placeholder="选文地址（选填）" name="source" class="am-form-field" value="{$blog.source}" required/>
        </div>

        <!--有效期-->

        <div class="form-group has-feedback">
            <label class=" control-label">有效期</label>
            <php>
                if(!isset($data['dead_line'])){
                $data['dead_line']=time()+604800;
                }
            </php>

            <input type="text" value="{:date('Y-m-d H:i',$data['dead_line'])}" id="datetimepicker" name="dead_line"
                   class="am-form-field">

        </div>

        <div class="am-form-group">
            <label>摘要</label>
            <textarea class="" type="text" name="description" placeholder="简单描述一下资讯的内容（选填）"
                      style="width: 100%;padding: 5px">{$blog.description}</textarea>
        </div>


        <div class="am-form-group weibo_post_box">
            <label>详情</label>
            <textarea minlength="10" name="content">{$blog.detail.content}</textarea>
        <!--插入图片表情-->
        <!--表情-->
        <a class="am-fl"  href="javascript:"data-url=" {:U('Core/Expression/getSmile')}" onclick="insertFace($(this))"style="margin-top: 3px">
            <img src="__CORE_IMAGE__/bq.png">
        </a>
        <div id="emot_content" class="emot_content"></div>

        <!--表情-->
            <div class="fileupload-buttonbar">
                <a type="button" class="am-btn am-btn-sm am-fl " style="  line-height: 0.2;"><img
                        src="__IMG__/image.png"></a>

                <div class="fileinput-button" style="width: 100%">
                    <input type="file" name="files" class="btn" id="choose"
                           style="left: 35px;position:absolute;z-index: 1;width: 35px;height:40px;opacity: 0;cursor: pointer;"
                           data-url="{:U('Core/File/uploadPictureBase64')}" multiple/></div>

                <style>
                    .img-list li {
                        float: left;
                        position: relative;
                        display: inline-block;
                        width: 100px;
                        height: 100px;
                        margin: 5px 5px 20px 5px;
                        border: 1px solid rgb(100, 149, 198);
                        background: #fff no-repeat center;
                        background-size: cover;
                        border-radius: 10px;
                    }
                </style>
            </div>
        <!--插入图片表情结束-->
        </div>
        <button type="button" id="confirm" class="am-btn am-btn-primary am-btn-block" style="margin: 20px 0px">发表
        </button>
        <ul class="img-list am-fl" style="padding-left:0px;">
            <!--图片显示区域-->
        </ul>
    </form>


</div>
    <script type="text/javascript">
    add_one_img();
    add_img();
    $('#datetimepicker').datetimepicker({
        format: 'yyyy-mm-dd hh:ii'
    });

    $('#confirm').click(function () {
        var data = $("#send_blog").serialize();
        var url = $("#send_blog").attr('data-url');
        $.post(url, data, function (msg) {
            if (msg.status == 1) {
                toast.success(msg.info);
                setTimeout(function () {
                    window.location.href = document.referrer
                },1000)
            } else {
                toast.error(msg.info);
            }
        }, 'json');
    });



    var ids = $('#one_img_id').val();
    if (ids==0) {
        $('.show_cover').hide();
    } else {
        $('.show_cover').show();
    }
</script>
</block>
